package org.example.mapreduce.factory;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.example.mapreduce.FlowWritable;
import org.example.mapreduce.PhoneCount;
import org.example.mapreduce.count.FlowCountCombiner;
import org.example.mapreduce.count.FlowCountMapper;
import org.example.mapreduce.count.FlowCountReducer;

import java.io.IOException;

/**
 * @author zhl
 * @version 1.0
 * @ClassName
 * @date 2020/11/12 19:33
 */
public class CountJobFactory extends AbstractJobFactory{

    @Override
    public Job getJob(Configuration conf) throws IOException {
        Job job = Job.getInstance(conf, "flow count");
        job.setJarByClass(PhoneCount.class);
        job.setMapperClass(FlowCountMapper.class);
        job.setReducerClass(FlowCountReducer.class);
        job.setCombinerClass(FlowCountCombiner.class);


        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(FlowWritable.class);

        job.setOutputKeyClass(FlowWritable.class);
        job.setOutputValueClass(NullWritable.class);
        return job;
    }
}
